<%@ page import="service.SContactService" %>
<%@ page import="service.impl.SContactServiceImpl" %>
<%@ page import="pojo.Supplier" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2024/1/3
  Time: 18:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<h2>添加供应商联系人</h2>
<form method="post" action="add" onsubmit="return isNull()">
    <table>
        <tr>
            <td>联系人姓名：</td>
            <td><input type="text" name="cname" id="cname" placeholder="请输入联系人姓名"></td>
        </tr>
        <tr>
            <td>联系人年龄：</td>
            <td><input type="text" name="age" id="age" placeholder="请输入密码"></td>
        </tr>
        <tr>
            <td>手机号：</td>
            <td><input type="text" name="mobile" id="mobile" placeholder="请输入手机号"></td>
        </tr>
        <tr>
            <td>创建日期：</td>
            <td><input type="date" name="createdate" id="createdate"></td>
        </tr>
        <tr>
            <td>所属供应商：</td>
            <td>
                <select name="pid" id="pid">
                    <option value="0">—请选择—</option>
                    <%
                        SContactService scs = new SContactServiceImpl();
                        List<Supplier> suppliers = scs.SupplierList();
                        for (Supplier supplier : suppliers) {

                    %>
                    <option value="<%=supplier.getId()%>"><%=supplier.getSname()%>
                    </option>

                    <%
                        }
                    %>
                </select>
            </td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" value="添加"></td>
        </tr>
    </table>
</form>

<script src="js/jquery.js"></script>
<script>
    function isNull() {
        if ($('#cname').val() == '') {
            alert("联系人姓名不能为空")
            return false
        }
        if ($('#age').val() == '') {
            alert("联系人年龄不能为空")
            return false
        }
        if ($('#mobile').val() == '') {
            alert("手机号不能为空")
            return false
        }
        if ($('#createdate').val() == '') {
            alert("创建日期不能为空")
            return false
        }
        if ($('#pid').val() == 0) {
            alert("所属供应商不能为空")
            return false
        }

        return true
    }
</script>

</body>
</html>
